<?php
/**
 * Author Yulin
 * Email  dwzhanglong@126.com
 * Date   2017-6-3
 * Func   充值
 */
defined('IN_YuLin') || exit('NO PERMIT!');

$table = Table('user_money_recharge');
$utable = Table('user');

if($a == 'add')
{
	
}
else
{
	$statuss = ['未支付','已支付'];
	$payments = ['alipay'=>'支付宝','weixin'=>'微信','bank'=>'银行卡','admin'=>'后台充值'];
	
	$data  = array();
	$where = ' FROM '.$table.' t LEFT JOIN '.$utable.' u ON t.uid = u.id LEFT JOIN '.Table('user_status').' s ON t.uid = s.uid WHERE s.upuid = '.$_uid;
    
    $uid = intval($_GET['uid']);
	$uid && $where .= ' AND t.uid = '.$uid;
	
	//	时间
	$dt1 = NoBadStr($_GET['dt1']);
	$dt1 && $where .= ' AND t.dateline >= '.strtotime($dt1);
	$dt2 = NoBadStr($_GET['dt2']);
	$dt2 && $where .= ' AND t.dateline <= '.strtotime($dt2);
    
    $payment = NoBadStr($_GET['payment']);
	$payment && $where .= ' AND t.payment = \''.$payment.'\'';
    
	$where .= ' AND t.status = 1 ';
    //$status = intval($_GET['status']);
	//$status && $where .= ' AND t.status = '.($status > 0 ? $status : 0);
    
	$title = NoBadStr($_GET['title']);
	$title && $where .= ' AND (t.notes LIKE \'%'.$title.'%\' OR u.username LIKE \''.$title.'\') ';

	$tmp = $db->getrow('SELECT COUNT(1) AS p '.$where);
	if($tmp['p'])
	{
		$page = max(1,intval($_GET['page']));
		$size = 20;
		$limit    = ' LIMIT '.($page - 1) * $size.','.$size;
		
		$orderby = ' ORDER BY t.id DESC ';
		$url = '?m='.$m.'&c='.$c.'&a='.$a.'&title='.$title.'&status='.$status.'&uid='.$uid.'&payment='.$payment.'&dt1='.$dt1.'&dt2='.$dt2;
		
		$data = $db->getall('SELECT t.*,u.username '.$where.$orderby.$limit);
		
		$multi = Multi($url,$page,$tmp['p'],$size);
	}
	
	$tpl->display('user/recharge');
}